load("../data/aiid/processed/AIID_subset_confirmatory.RData")
data_trimmed <- AIID_subset_confirmatory %>%
#filter(exclude_iat_stricter == FALSE) %>%
filter(english_fluency %in% c("English fluent - speak/read it regularly", "English is my primary language")) |>
dplyr::select(user_id,
domain,
age,
sex,
english_fluency,
exclude_iat_stricter,
block_order,
iat_type,
D,
# self-report attitudes data
prefer,
others_prefer,
actual_x, actual_y,
actual_diff,
gut_x, gut_y,
# individual differences scales data
individual_differences_measure,
individual_differences_sum_score)
dat_subset <- data_trimmed |>
filter(domain %in% c("Poor People - Rich People",
"Conservatives - Liberals",
"Burger King - McDonald's",
"Protestants - Catholics"))
dat_r <- dat_subset |>
group_by(domain) |>
summarise(n = n(),
mean_prefer = mean(prefer, na.rm = TRUE),
mean_actual_diff = mean(actual_diff, na.rm = TRUE),
mean_actual_x = mean(actual_x, na.rm = TRUE),
mean_actual_y = mean(actual_y, na.rm = TRUE),
sd_prefer = sd(prefer, na.rm = TRUE),
sd_actual_diff = sd(actual_diff, na.rm = TRUE),
sd_actual_x = sd(actual_x, na.rm = TRUE),
sd_actual_y = sd(actual_y, na.rm = TRUE),
r_prefer_actual = broom::tidy(cor.test(actual_diff, prefer, use = "pairwise.complete.obs")),
r_actuals = broom::tidy(cor.test(actual_x, actual_y, use = "pairwise.complete.obs"))) |>
#r_gut = cor(gut_x, gut_y, use = "pairwise.complete.obs"),
#r_selfother = cor(prefer, others_prefer, use = "pairwise.complete.obs")) |>
unnest(r_prefer_actual, names_sep = "_") |>
unnest(r_actuals, names_sep = "_") |>
mutate_if(is.numeric, janitor::round_half_up, digits = 2) |>
select(domain, n,
mean_prefer, mean_actual_diff, mean_actual_x, mean_actual_y,
sd_prefer, sd_actual_diff, sd_actual_x, sd_actual_y,
r_prefer_actual = r_prefer_actual_estimate, r_prefer_actual_lower = r_prefer_actual_conf.low, r_prefer_actual_upper = r_prefer_actual_conf.high,
r_actuals = r_actuals_estimate, r_actuals_lower = r_actuals_conf.low, r_actuals_upper = r_actuals_conf.high)
# dat_r |>
# kable() |>
# kable_classic(full_width = FALSE)
dat_r |>
select(domain, n,
r_prefer_actual, r_actuals) |>
kable() |>
kable_classic(full_width = FALSE)
plot actual feelings towards x vs y items
mean_sd_points <- dat_subset %>%
group_by(domain) %>%
summarise(
mean_x = mean(actual_x, na.rm = TRUE),
mean_y = mean(actual_y, na.rm = TRUE),
sd_x = sd(actual_x, na.rm = TRUE),
sd_y = sd(actual_y, na.rm = TRUE)
)
ggplot(dat_subset, aes(actual_x, actual_y)) +
geom_jitter(alpha = 0.4) +
# Red mean dot
geom_point(
data = mean_sd_points,
aes(x = mean_x, y = mean_y),
color = "red",
size = 3,
inherit.aes = FALSE
) +
# Optional: add SD error bars (crosshairs)
geom_errorbar(
data = mean_sd_points,
aes(x = mean_x, ymin = mean_y - sd_y, ymax = mean_y + sd_y),
color = "red",
width = 0,
inherit.aes = FALSE
) +
geom_errorbarh(
data = mean_sd_points,
aes(y = mean_y, xmin = mean_x - sd_x, xmax = mean_x + sd_x),
color = "red",
height = 0,
inherit.aes = FALSE
) +
facet_wrap(~ domain) +
scale_x_continuous(breaks = scales::breaks_pretty(10)) +
scale_y_continuous(breaks = scales::breaks_pretty(10)) +
coord_fixed() +
coord_cartesian(xlim = c(0.5, 10.5), ylim = c(0.5, 10.5))

plot prefer vs actual items
mean_sd_points <- dat_subset %>%
group_by(domain) %>%
summarise(
mean_y = mean(actual_diff, na.rm = TRUE),
mean_x = mean(prefer, na.rm = TRUE),
sd_y = sd(actual_diff, na.rm = TRUE),
sd_x = sd(prefer, na.rm = TRUE)
)
ggplot(dat_subset, aes(actual_diff, prefer)) +
geom_jitter(alpha = 0.4) +
# Red mean dot
geom_point(
data = mean_sd_points,
aes(x = mean_x, y = mean_y),
color = "red",
size = 3,
inherit.aes = FALSE
) +
# Optional: add SD error bars (crosshairs)
geom_errorbar(
data = mean_sd_points,
aes(x = mean_x, ymin = mean_y - sd_y, ymax = mean_y + sd_y),
color = "red",
width = 0,
inherit.aes = FALSE
) +
geom_errorbarh(
data = mean_sd_points,
aes(y = mean_y, xmin = mean_x - sd_x, xmax = mean_x + sd_x),
color = "red",
height = 0,
inherit.aes = FALSE
) +
facet_wrap(~ domain) +
scale_x_continuous(breaks = scales::breaks_pretty(10)) +
scale_y_continuous(breaks = scales::breaks_pretty(7)) +
coord_fixed() +
coord_cartesian(xlim = c(-10.5, 10.5), ylim = c(-3.5, +3.5))
